<template>
	<view class="tabs">
		<view class="tabs-buy-list">
			<block v-for="(item, index) in myBillList" :key="index">
				<view class="tbl-item">
					<view class="item buy-type one">
						{{ item.formatDate }}
					</view>
					<text class="item" :class="[item.priceType ? 'add' : 'subtract']">
						{{ item.priceType ? '+' : '-'}}{{item.price}}
					</text>
					<view class="item">{{ item.mprice }}</view>
					<view class="item note">{{ item.note }}</view>
				</view>
			</block>
		</view>
		<loadding-more 
			 :loadEnd="loadEnd"
		 ></loadding-more>
	</view>
</template>

<script>
import LoaddingMore from '../../../../components/loadding-more.vue';
export default {
	props: {
		activeTAB: {
			type: Number
		}
	},
	components: {
		LoaddingMore
	},
	data() {
		return {
			page: 1,
			myBillList: [],
			loadEnd: false,
			stop: false
		};
	},
	onShow() {
	},
	methods: {
		priceDatail(type) {
			console.log('----2', type)
			if (this.loadEnd) return
			this.$http.priceDatail({
				page: this.page,
				size: 10,
				payType: type,
			}).then(res => {
				const data = res.data;
				const totalPage =  Math.ceil(data.data.total/10)
				if (data.success) {
					this.stop = false
					this.myBillList.push(...data.data.rows)
					if (totalPage >= this.page) {
						this.loadEnd = data.data.total/this.page < 10 ? true : false;
						this.page += 1;
						return
					}
					this.loadEnd = true
					return
				}
				uni.showToast({
					title: data.errMsg,
					icon: 'none'
				});
				this.loadEnd = true
			});
		}
	},
	onReachBottom () {
		if (this.activeTAB !== 1) return;
		if (this.stop) return
		this.stop = true
		this.priceDatail();
	}
};
</script>

<style scoped lang="scss">
@import '../../../../common/tabs.scss';
</style>
